
Scene = { };
ActiveScenes = { };
DeadScenes = { };

function Scene.Clear()
	
	ActiveScenes = { };
	DeadScenes = { };
	
end

function Scene.DoAt( name, time, func )

	if( DeadScenes[name] ) then
		return;
	end
	
	if( ActiveScenes[name] and
		ActiveScenes[name] + time < GetTicks() ) then

		func();
		
	end
	
end

function Scene.Do( name, func )
	
	if( DeadScenes[name] ) then
		return;
	end
	
	func();
	
	if( not ActiveScenes[name] ) then
		ActiveScenes[name] = GetTicks();
	end
	
end

function Scene.Once( name, func )
	
	if( ActiveScenes[name] or
		DeadScenes[name] ) then
		return;
	end
	
	func();
	
	ActiveScenes[name] = GetTicks();
	
end

function Scene.End( name )
	
	ActiveScenes[name] = nil;
	DeadScenes[name] = GetTicks();
	
end

function Scene.IsOver( name )
	
	if( DeadScenes[name] == nil ) then
		return false;
	end
	
	return true;
	
end